package leecode

func returnToBoundaryCount(nums []int) int {
	prefix := make([]int, len(nums)+1)
	for i := 0; i < len(nums); i++ {
		prefix[i+1] = prefix[i] + nums[i]
	}
	var result int
	for _, pre := range prefix {
		if pre == 0 {
			result++
		}
	}
	return result - 1
}
